package com.godpaper.as9.commands
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.godpaper.as9.bussiness.delegates.UserDelegate;
	import com.godpaper.as9.events.GetUserListEvent;
	import com.godpaper.as9.model.UserModelLocator;
	import com.godpaper.as9.vo.UserVO;
	
	import mx.rpc.IResponder;

	public class GetUserListCommand extends CommandBase implements ICommand, IResponder
	{
		private var delegate:UserDelegate;
		private var getUserListEvent:GetUserListEvent;
		private var userModel:UserModelLocator = UserModelLocator.getInstance();
		public function GetUserListCommand()
		{
			super();
			delegate = new UserDelegate(this);
		}
		
		override public function execute(event:CairngormEvent):void
		{
			getUserListEvent = GetUserListEvent(event);
			delegate.read(null);
		}
		
		override public function result(data:Object):void
		{
//			userModel.userList.source = data.result;
			userModel.userList.disableAutoUpdate();
			userModel.userList.removeAll();
			for(var i:int=0;i<data.result.length;i++)
			{
				var vo:UserVO = new UserVO();
				vo.capcity_message = data.result[i].capcity_message;
				vo.capcity_upload = data.result[i].capcity_upload;
				vo.cno = data.result[i].cno;
				vo.email = data.result[i].email;
				vo.is_admin = data.result[i].is_admin;
				vo.is_super_admin = data.result[i].is_super_admin;
				vo.messaged = data.result[i].messaged;
				vo.name = data.result[i].name;
				vo.once_belonged = data.result[i].once_belonged;
				vo.password = data.result[i].password;
				vo.registed_time = data.result[i].registed_time;
				vo.sno = data.result[i].sno;
				vo.uploaded = data.result[i].uploaded;
				userModel.userList.addItem(vo);
			}
			userModel.userList.enableAutoUpdate();
			userModel.userList.refresh();
		}
		
	}
}